#!/usr/bin/env bash
# shellcheck disable=SC2103

# Test vfox backend with npm plugin (plugin:tool format) using vfox-npm submodule

# Link the vfox-npm plugin from the submodule
mise plugins link vfox-npm "$ROOT/test/plugins/vfox-npm"

# Test plugin:tool format with assertions
latest_version=$(mise latest vfox-npm:prettier)
partial_version=$(echo "$latest_version" | cut -d. -f1-2)
assert_contains "mise ls-remote vfox-npm:prettier" "$partial_version."
mise install "vfox-npm:prettier@$latest_version"
assert "mise use vfox-npm:prettier@$latest_version"
assert_contains "mise exec -- prettier --version" "$latest_version"

# Test uninstall functionality
assert "mise uninstall vfox-npm:prettier@$latest_version"
assert_directory_not_exists "$MISE_DATA_DIR/installs/vfox-npm/prettier/$latest_version"
